import { Module, OnModuleInit } from '@nestjs/common';
import { DataSource } from 'typeorm';

import { ConfigurationModule } from '@src/config/configuration.module';

import { runSeeds } from './seed';

@Module({
  imports: [ConfigurationModule],
})
export class DatabaseModule implements OnModuleInit {
  constructor(private readonly dataSource: DataSource) {}

  async onModuleInit(): Promise<void> {
    await runSeeds(this.dataSource);
  }
}
